/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Engine2D.camera;

import Engine2D.engine.Engine;
import Engine2D.level.Level;

/**
 *
 * @author Garys
 */
public class Camera {
    
    /**
     * 
     */
    public int x;
    /**
     * 
     */
    public int y;
    /**
     * 
     */
    public int xScroll;
    /**
     * 
     */
    public int yScroll;
    /**
     * 
     */
    public Level level;
    
    /**
     * 
     */
    public Camera() {
        this.x = 0;
        this.y = 0;
    }
            
    /**
     * 
     * @param x
     * @param y
     */
    public Camera(int x, int y) {
        this.x = x;
        this.y = y;
    }
    
    /**
     * 
     */
    public void tick() {
        xScroll = x - (Engine.getInstance().w - 16) / 2;
        yScroll = y - (Engine.getInstance().h - 32) / 2;

        if (xScroll < 0) {
            xScroll = 0;
        }
        if (yScroll < 0) {
            yScroll = 0;
        }

        if (xScroll > level.w * 32 - Engine.getInstance().w) {
            xScroll = level.w * 32 - Engine.getInstance().w;
        }
        if (yScroll > level.h * 32 - Engine.getInstance().h) {
            yScroll = level.h * 32 - Engine.getInstance().h;
        }
    }
    
}
